import java.util.Arrays;

public class OddBeforeEven {

    public static void change(int[] arr) {
        int n = arr.length;
        while (n != 0) {
            for (int i = 0; i < arr.length - 1; i++) {
                if (arr[i] % 2 == 0 && arr[i + 1] % 2 != 0) {
                    int tmp = arr[i];
                    arr[i] = arr[i + 1];
                    arr[i + 1] = tmp;
                }
            }
            n -= 1;
        }
    }

    public static void main(String[] args) {
        int[] arr = {1, 2 ,3 ,4, 5, 6};
        change(arr);
        System.out.println(Arrays.toString(arr));
    }
}
